<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

// 函数改为异步函数的方法(asyns)
    // 命名函数
        // async function fn(){}
    // 匿名函数
        var fn = async function() {
            var obj = {
                name:"周宇",
                age:20,
                async success(){
                    console.log(hhh);
                }
            }
        }
    


// console.log() 表明了代码 执行顺序
    function randNum() {
        console.log(333);
        return new Promise(function (resolve,reject) {
            console.log(444);
            setTimeout(function() {
                console.log(666);
                var num = Math.round(Math.random() * 100);
                resolve(num)
            },2000);
        });
    };
// async相当于对promise进行封装
    async function fn() {
        console.log(222);
        var num =  await randNum();
        console.log(777)
        console.log(num);
    }

    console.log(111);
    console.log(fn());
    console.log(555)
</script>
</html>